{extend name="light-year/layout/master/detail" /}

{block name="title"}Banner管理{/block}
{block name="page-title"}Banner{/block}

{block name="content"}
<input name="banner_id" class="form-control" type="hidden" value="{if $detail}{$detail->banner_id}{/if}" />
<input name="banner_content" class="form-control" type="hidden" value="{if $detail}{$detail->banner_content}{/if}" />
<div class="form-group">
    <label><span class="text-danger">*</span> Banner标题：</label>
    <input type="text" class="form-control" name="banner_title" value="{if $detail}{$detail->banner_title}{/if}" placeholder="输入Banner标题" />
    <small class="help-block">
        <i class="mdi mdi-information"></i>
        唯一标识
    </small>
</div>
<div class="form-group">
    <label>
        封面：
    </label>
    <div>
        <input type="hidden" name="banner_cover" value="{if $detail}{$detail->banner_cover}{/if}"/>
        <div id="banner_cover">
            <div id="banner_cover_filePicker"><i class="icon-cloud-upload"></i></i> 选择单张图片</div>
        </div>
    </div>
    <small class="help-block">
        <i class="mdi mdi-information"></i>
        Banner的封面图
    </small>
</div>
<div class="form-group">
    <label> Banner外链：</label>
    <input type="url" class="form-control" name="banner_url" value="{if $detail}{$detail->banner_url}{/if}" placeholder="输入外链" />
</div>
<div class="form-group">
    <label> 文字描述：</label>
    <textarea class="form-control" rows="5" name="banner_words" placeholder="请输入文字描述" >{if $detail}{$detail->banner_words}{/if}</textarea>
</div>
<div class="form-group">
    <label> 排序：</label>
    <input type="number" class="form-control" name="banner_sort" value="{if $detail}{$detail->banner_sort}{else/}1{/if}" placeholder="输入排序" />
    <small class="help-block">
        <i class="mdi mdi-information"></i>
        从小到大，升序
    </small>
</div>
<div class="form-group">
    <label>
        是否启用：
    </label>
    <div class="clearfix">
        <label class="lyear-radio radio-inline radio-primary">
            <input type="radio" name="is_check" value="1" {if (empty($detail) || $detail->is_check === 1) }checked{/if}><span>启用</span>
        </label>
        <label class="lyear-radio radio-inline radio-primary">
            <input type="radio" name="is_check" value="0" {if (empty($detail) || $detail->is_check === 0) }checked{/if}><span>禁用</span>
        </label>
    </div>
</div>
<div class="form-group">
    <button type="submit" class="btn btn-primary ajax-post" target-form="add-form">确 定</button>
    <button type="button" class="btn btn-default" onclick="javascript:history.back(-1);return false;">返 回</button>
</div>
{/block}

{block name="script"}
{include file="light-year/layout:plugins/webuploader" /}
<script type="text/javascript">
    window.onload = function () {
        closeLayerLoading(closeAllLayer);

        // 图片上传组件
        webUploaderImgs('#banner_cover_filePicker', '', '#banner_cover', 'input[name=banner_cover]', {'img_limit':1, 'single_graph_type':1});

        // 详情图片渲染（使用这种方式，可以共用图片上传限制等功能）
        let detail = JSON.parse('{:html_get_res_from_admin($detail)}');
        if (detail && !isEmpty(detail.banner_cover)){
            $('#banner_cover').append(webUploaderImgHtml(detail.banner_cover, 'input[name=banner_cover]', $('#banner_cover_filePicker').attr('span-class')));
        }
    }
</script>
{/block}